var asynx = function(query) {
	return asynx.$(query, arguments[1]);
};

asynx.namespace = function(sNameSpace) {
	var levels = sNameSpace.split(".");
	var curLevel = asynx;
	for (var i = (levels[0] == "asynx") ? 1 : 0; i < levels.length; i++) {
 		curLevel[levels[i]] = curLevel[levels[i]] || {};
		curLevel = curLevel[levels[i]];
	};
	return curLevel;
};
	
asynx.extend = function() {
	var obj = arguments[0];
	var target = arguments[1];
	
	for (i in target) {
		obj[i] = target[i];
	}
	
	return obj;
};

asynx.getAsynxPath = function() {
	var r = /[\/]asynx[^\/js]*\.js$/g, p = "./";
	asynx('//script').each(function(s){
		if (r.test(s.src)) p=s.src.replace(r,"");
	});
	return p;
};

asynx.namespace("impl.core");

asynx.impl.core = {
	
	userAgent: navigator.userAgent.toLowerCase(),
	isSafari: false,
	isOpera: false,
	isIE: false,
	isFirefox: false,
	
	init: function() {
		window.asynx$ = asynx.$;  		
	},
	
	$: function() {
		var expression = arguments[0], s = arguments[1];
		var nodes = new asynx.selector(expression, s);
		return nodes;
	},
	
	browser: function() {
		this.isSafari = !!(/webkit/.test(this.userAgent));
		this.isOpera = !!(/opera/.test(this.userAgent));
		this.isIE = !!(/msie/.test(this.userAgent) && !/opera/.test(this.userAgent));
		this.isFirefox = !!(/mozilla/.test(this.userAgent) && /firefox/.test(this.userAgent));
	}
	
};

asynx.extend(asynx, asynx.impl.core);
asynx.init();
asynx.browser();
delete asynx.impl.core;

asynx.namespace("globals");
asynx.namespace("globals.plugins.cache");
asynx.namespace("globals.ajax.threads");
asynx.namespace("globals.ajax.config");
asynx.namespace("globals.ajax.urlModifiedDates");
asynx.namespace("globals.cookies.cookiesCached");
asynx.namespace("globals.drag.lastzIndex");
asynx.globals.plugins = {};
asynx.globals.plugins.cache = {};
asynx.globals.ajax.threads = [];
asynx.globals.ajax.config = {};
asynx.globals.ajax.urlModifiedDates = {};
asynx.globals.drag.lastzIndex = 0;






var log = function(l) {
	asynx('log').appendHtml(l+"<br>");
	asynx('log').css({
		width: '400px',
		position: 'absolute',
		right: '0px',
		top: '0px',
		bg: '#E8EEF7',
		border: '1px #C3D9FF solid',
		fontSize: '9px',
		fontFamily: 'Arial'
	});
};
